<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Mihail Merkov
 * Date: 13-8-11
 * Time: 20:10
 * To change this template use File | Settings | File Templates.
 */

namespace TennisTournament\Service;

/**
 * GenericService interface. Support CRUD operation.
 * @package TennisTournament\Service
 */
interface GenericService {
    /**
     * Get an entity by its {@link $id}
     * @param $id integer
     * @return an entity if have with such id or null otherwise
     * @throws \Exception
     */
    public function get($id);

    /**
     * Get all entities from specific type
     * @return Array from all entities from specific type
     * @throws \Exception
     */
    public function fetchAll();

    /**
     * Save an specific entity;
     * @param entity
     * @return void
     * @throws \Exception
     */
    public function save($entity);

    /**
     * Delete an specific entity;
     * @param entity
     * @return void
     * @throws \Exception
     */
    public function delete($entity);
}